export function getScale_out(x) {
    //  -x  0 x
    if (x >= 0) {
        return 1 - x;

    } else {
        // return 1 + x;
        return 1
    }
}

export function getScale_into(x) {
    //  -x  0 x
    if (x >= 0) {
        // return 1 - x;.
        return 1
    } else {
        return 1 + x;
    }
}

export function getPageY(x) {
    if (x < 0) {
        // x <= -1 &&
        return Math.ceil(Math.abs(x))
    }
    if (x == 0) {
        return 0
    }
    if (0 < x) {
        // && x <= Math.ceil(x)
        return Math.ceil(x)
    }
}

function getDownSaleIndex(length, index) {
    if (index < 0) {
        index = length + index
        if (index < 0) {
            return getDownSaleIndex(length, index)
        }
    }
    if (index >= 0) {
        return index
    }
}

function getUpSaleIndex(length, index) {
    if (index > length - 1) {
        index = index - length
        if (index > length - 1) {
            return getUpSaleIndex(length, index)
        }
    }
    if (index <= length - 1) {
        return index
    }
}

export function getInArray(_array, index) {
    if (index < 0) {
        index = getDownSaleIndex(_array.length, index)
    }
    if (index > 0) {
        index = getUpSaleIndex(_array.length, index)
    }

    return _array[index]
}

export function getTranslateY(x) {
    if (x <= -1 && x <= 1) {
        return x
    }
    return x
}